/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package es.srn.utils.plantillas;


import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.Timer;

/**
 *
 * @author Alumno
 */
public class FrmReloj extends JFrame{
    

    public static SimpleDateFormat formatoDeFecha = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    
    public FrmReloj() {
      super("Timer Demo");
      setSize(100, 50);      
      setResizable(false);
      this.setAlwaysOnTop(true);
      setDefaultCloseOperation(EXIT_ON_CLOSE);

      ClockLabel clock = new ClockLabel();
      getContentPane().add(clock, BorderLayout.NORTH);
      
      
    }

    public static void main(String args[]) {
      FrmReloj ct = new FrmReloj();
      ct.setVisible(true);
    }
  }
  class ClockLabel extends JLabel implements ActionListener {

    public ClockLabel() {
      super("" + FrmReloj.formatoDeFecha.format(new Date()));
      Timer t = new Timer(1000, this);
      t.start();
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
      //setText((new Date()).toString());
      setText(FrmReloj.formatoDeFecha.format(new Date()));
    }
  
  }
    
    

